package com.qkjia.consumer;


import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

@Component
@Slf4j
//@ConditionalOnExpression("'${spring.profiles.active}'.equals('dev')")
public class DeviceConsumer {

    @KafkaListener(topics = "testTopic00002")
    public void deviceTest(@Payload ConsumerRecord consumerRecord, Acknowledgment ack) {
        Object value = consumerRecord.value();
        log.info("deviceValue="+value);
        ack.acknowledge();
    }

//    @KafkaListener(topics = "testTopic00001",groupId = "deviceGroup01")
    @KafkaListener(topics = "testTopic00001")
    public void deviceTest01(@Payload ConsumerRecord consumerRecord, Acknowledgment ack) {
        Object value = consumerRecord.value();
        log.info("deviceValue="+value);
        ack.acknowledge();
    }
}
